The k-nearest neighbours using the alpha-distance: The k-nearest neighbours using the \(alpha\)-distance
Description
The k-nearest neighbours using the \(alpha\)-distance.
Usage
alfann(xnew, x, a, k = 10, rann = FALSE)
Arguments
xnew
A matrix or a vector with new compositional data.
x
A matrix with the compositional data.
a
The value of the power transformation, it has to be between -1 and 1. If zero values are present it has to be greater than 0. If \(\alpha=0\), the isometric log-ratio transformation is applied.
k
The number of nearest neighbours to search for.
rann
If you have large scale datasets and want a faster k-NN search, you can use kd-trees implemented in the R package "RANN". In this case you must set this argument equal to TRUE. Note however, that in this case, the only available distance is by default "euclidean".
Value
A matrix including the indices of the nearest neighbours of each xnew from x.
Details
The \(\alpha\)-transformation is applied to the compositional data first and the indices of the k-nearest neighbours using the Euclidean distance are returned.
References
Michail Tsagris, Abdulaziz Alenazi and Connie Stewart (2020).
The alpha-k-NN- regression for compositional data.
https://arxiv.org/pdf/2002.05137.pdf
# NOT RUN {library(MASS)
xnew <- as.matrix(fgl[1:20, 2:9])
xnew <- xnew / rowSums(xnew)
x <- as.matrix(fgl[-c(1:20), 2:9])
x <- x / rowSums(x)
b <- alfann(xnew, x, a = 0.1, k = 10)
# }